package cn.z2huo.algorithm.allArray;

public class Main {
    public void getAllArray(int[] array, int start){
        if(start == array.length-1){
            for (int i = 0; i < array.length; i++) {
                System.out.print(array[i]);
            }
            System.out.println();
        }else{
            for (int i = start; i < array.length; i++) {
                if(array[start]!=array[i]){
                    swapNum(array, start, i);
                    getAllArray(array, start+1);
                    swapNum(array, start, i);
                }
            }
        }
    }

    public void swapNum(int[] array, int i, int j){
//        array[j] += array[i];
//        array[i] = array[j] - array[i];
//        array[j] -= array[i];

        int flag = array[j];
        array[j] = array[i];
        array[i] = flag;

//        array[j] = array[j]^array[i];
//        array[i] = array[j]^array[i];
//        array[j] = array[j]^array[i];

    }

    public static void main(String[] args){
        int[] array = {1,2,3};
        Main main = new Main();
        main.getAllArray(array, 0);
    }
}
